<?php
header("Content-type: text/html; charset=utf-8");
include "TopSdk.php";
//...SDK...top..TopClient.php.8.$gatewayUrl........:http://gw.api.tbsandbox.com/router/rest, 
//..............:http://gw.api.taobao.com/router/rest 

//...TopClient. 
$c = new TopClient;
$c->appkey = "12695768";
$c->secretKey = "2ba13d59ec94911a8707eceaa17c58fa";

$db = mysql_connect("grouplife", "tutorial", "86249317lijie");

mysql_select_db("grouplife",$db);

//......API....
//$req = new PosterChannelsGetRequest;
//..API....... 
//$resp = $c->execute($req); 
$req = new ShopcatsListGetRequest;
$req->setFields("cid,parent_cid,name,is_parent");
$resp = $c->execute($req);
foreach($resp->shop_cats->shop_cat as $cat) {
        echo "cid: " . $cat->cid . "\n";
        echo "name: " . $cat->name . "\n";
        echo "parent_cid: " . $cat->parent_cid . "\n";
        $sql = "INSERT INTO category(name, cid, created, updated) values(\"$cat->name\", $cat->cid, current_timestamp, current_timestamp)";
        print $sql . "\n";
        $result = mysql_query($sql);
}
?>

